package com.leokok.jts.learning.jts.core.operation.linemerge;

import org.junit.Test;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.operation.linemerge.LineMerger;

import java.util.Collection;

public class LineMergeTest {

    @Test
    public void lineMergeTest() throws ParseException {
        WKTReader wktReader = new WKTReader();
        Geometry geometry1 = wktReader.read("LINESTRING (115.99563000000002 31.988840000000003, 115.99574000000001 31.988850000000003, 115.99587000000001 31.988880000000005, 115.99592000000001 31.988840000000003, 115.996085 31.988766)");
        Geometry geometry2 = wktReader.read("LINESTRING (115.996085 31.988766, 115.99615000000001 31.988810000000004, 115.99616000000002 31.988850000000003, 115.99622000000002 31.988880000000005, 115.99630000000002 31.988880000000005, 115.99635000000002 31.988880000000005, 115.99637000000001 31.988900000000005, 115.99638000000002 31.988920000000004, 115.996425 31.988965)");

        LineMerger lineMerger = new LineMerger();
        lineMerger.add(geometry1);
        lineMerger.add(geometry2);

        Collection mergedLineStrings = lineMerger.getMergedLineStrings();
        System.out.println(mergedLineStrings.size());


    }
}
